package com.gexiaobao.pigeon.ui.fragment.mall

import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.ListView
import android.widget.TextView
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.LinearLayoutManager
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.BaseFragment
import com.gexiaobao.pigeon.app.eventViewModel
import com.gexiaobao.pigeon.app.ext.RxTextTool
import com.gexiaobao.pigeon.app.ext.init
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.app.ext.loadListData
import com.gexiaobao.pigeon.app.ext.loadServiceInit
import com.gexiaobao.pigeon.app.model.bean.CartCouponListResponse
import com.gexiaobao.pigeon.app.model.bean.GoodsSkuResponse
import com.gexiaobao.pigeon.app.model.bean.ShopCarListResponse
import com.gexiaobao.pigeon.app.model.param.AddOrReGoodsParam
import com.gexiaobao.pigeon.app.model.param.AddShoppingCarParam
import com.gexiaobao.pigeon.app.model.param.CarCheckedAllItemParam
import com.gexiaobao.pigeon.app.model.param.CarCheckedItemParam
import com.gexiaobao.pigeon.app.model.param.CheckCouponParam
import com.gexiaobao.pigeon.app.model.param.CheckOrCancelShopParam
import com.gexiaobao.pigeon.app.model.param.GenerateShopOrderParam
import com.gexiaobao.pigeon.app.network.ListDataUiState
import com.gexiaobao.pigeon.app.util.CacheUtil
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.app.util.KvUtils
import com.gexiaobao.pigeon.app.util.RxToast
import com.gexiaobao.pigeon.app.util.SettingUtil
import com.gexiaobao.pigeon.app.util.StatusBarUtil
import com.gexiaobao.pigeon.app.util.Util
import com.gexiaobao.pigeon.app.weight.recycleview.SpaceItemDecoration
import com.gexiaobao.pigeon.databinding.FragmentShopCarBinding
import com.gexiaobao.pigeon.ui.adapter.CouponListAdapter
import com.gexiaobao.pigeon.ui.adapter.ShopCarAdapter
import com.gexiaobao.pigeon.ui.adapter.SingleLevelAdapter
import com.gexiaobao.pigeon.ui.dialog.MyDialog
import com.gexiaobao.pigeon.ui.dialog.RxDialogDefault
import com.gexiaobao.pigeon.ui.mall.MallViewModel
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.kingja.loadsir.core.LoadService
import com.yanzhenjie.recyclerview.SwipeRecyclerView
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.navigateAction
import me.hgj.jetpackmvvm.ext.util.screenHeight
import me.hgj.jetpackmvvm.ext.util.screenWidth
import me.hgj.jetpackmvvm.ext.util.setOnclickNoRepeat
import java.math.BigDecimal

/**
 * @Author      : hxw
 * @Date        : 2023/6/28 11:35
 * @Describe    : 购物车
 */
class FragmentShoppingCart : BaseFragment<MallViewModel, FragmentShopCarBinding>() {

    private var totalSize: Int = 0
    private val mAdapter: ShopCarAdapter by lazy { ShopCarAdapter(arrayListOf()) }
    private lateinit var loadsir: LoadService<Any>
    private var singleRadioDialog: MyDialog? = null
    private var checkBean: GoodsSkuResponse.ListBean? = null
    private var clickItemPosition = -1

    /** 点击的具体某一条商品的position */
    private var goodsItemPosition = -1

    /** 记录购物车列表中选中的条目数量 */
    private var checkList = ArrayList<Int>()

    /** 接口中列表的数据 */
    private var goodsData = ArrayList<ShopCarListResponse.ListBean>()
    private var totalPrice: BigDecimal? = null
    private var dialogBottom: BottomSheetDialog? = null
    private var couponShopId = 0
    private var couponListType = 0
    private var addressId = 0

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        activity?.let { StatusBarUtil.setLightMode(it) }
        activity?.let { StatusBarUtil.setColor(it, Color.TRANSPARENT, 0) }
    }

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeWhiteBarMenu.tvWhiteTitle.text = "购物车"
        mDatabind.includeWhiteBarMenu.tvRedBarRightMenu.text = "移除失效商品"
        mDatabind.includeWhiteBarMenu.tvRedBarRightMenu.visibility = View.VISIBLE
        val addressData = CacheUtil.getAddressInfo()
        addressId = addressData?.id ?: 0
        initAdapter()
        handleAdapter()
    }

    override fun onBindViewClick() {
        super.onBindViewClick()
        setOnclickNoRepeat(
            mDatabind.includeWhiteBarMenu.ivBack,
            mDatabind.addToOrder,
            mDatabind.includeWhiteBarMenu.tvRedBarRightMenu,
            mDatabind.tvGoToShopping,
            mDatabind.llAllCheck,
            mDatabind.tvGoToCollect
        ) {
            when (it) {
                mDatabind.includeWhiteBarMenu.ivBack -> nav().navigateUp()
                mDatabind.llAllCheck -> chooseAllItem()
                mDatabind.tvGoToShopping ->
                    nav().navigateAction(R.id.action_to_fragment_mall_goods, Bundle().apply {
                        putInt("index", 0)
                    })

                mDatabind.includeWhiteBarMenu.tvRedBarRightMenu -> showRemoveInvalidDialog()
                mDatabind.addToOrder -> toOrderGoods()
                mDatabind.tvGoToCollect -> {
                    nav().navigateAction(R.id.action_to_fragment_collect_goods_list)
                }
            }
        }
    }

    override fun onResume() {
        super.onResume()
        onRefresh()
    }

    private fun onRefresh() {
        showLoadingAntiShake(getString(R.string.loading))
        mViewModel.getShopCartList()
    }

    @SuppressLint("NotifyDataSetChanged")
    override fun createObserver() {
        super.createObserver()
        /** 删除购物车 */
        mViewModel.deleteCarResult.observe(viewLifecycleOwner) {
            dialogDeleteCartOrder.dismiss()
            if (it.isSuccess) {
                eventViewModel.toRefreshList.value = true
                onRefresh()
            } else {
                RxToast.showToast(it.errorMsg)
            }
        }
        /** 移除已失效商品 */
        mViewModel.removeInvalidGoodResult.observe(viewLifecycleOwner) {
            if (it.isSuccess) {
                onRefresh()
                RxToast.showToast("失效商品已全部移除")
            } else {
                RxToast.showToast(it.errorMsg)
            }
        }
        /** 获取购物车列表 */
        mViewModel.shopCarResult.observe(viewLifecycleOwner) {
            dismissLoadingAntiShake()
            if (it.isSuccess) {
                loadListData(it, mAdapter, loadsir, mDatabind.layoutList.swipeRecyclerView, mDatabind.layoutList.swipeRefreshLayout)
                setUIStatus(it)
            } else {
                if (it.errCode == 1000009) {
                    mViewModel.getShopCartList()
                }
                RxToast.showToast(it.errMessage)
            }
        }
        /** 店铺选择或者取消 */
        mViewModel.checkShopResult.observe(viewLifecycleOwner) {
            onRefresh()
        }
        /** 购物车+- */
        mViewModel.addOrReGoodsResult.observe(viewLifecycleOwner) {
            onRefresh()
        }
        /** 获取商品详情 */
        mViewModel.goodsSkuResult.observe(viewLifecycleOwner) {
            dismissLoading()
            if (it?.list == null || it.list.size == 0) {
                return@observe
            }
            showSKuListDialog(it.list)
        }
        /** 更改所选规格 */
        mViewModel.changeCarSpecResult.observe(viewLifecycleOwner) {
            dismissLoading()
            onRefresh()
        }
        /** 单选或取消单选 */
        mViewModel.checkedResult.observe(viewLifecycleOwner) {
            dismissLoading()
            onRefresh()
        }
        /** 全部勾选或者全部取消 */
        mViewModel.allCheckedResult.observe(viewLifecycleOwner) {
            dismissLoading()
            onRefresh()
        }
        /** 购物车生成订单 */
        mViewModel.shopOrderResult.observe(viewLifecycleOwner) {
            dismissLoading()
            onRefresh()
            eventViewModel.toRefreshList.value = true
            nav().navigateAction(R.id.action_to_fragment_order_detail, Bundle().apply {
                putString("orderId", it.orderId.toString())
                putString("type", "detail")
            })
        }
        /** 购物获取可使用的优惠券列表 */
        mViewModel.cartCouponResult.observe(viewLifecycleOwner) {
            showBottomCouponDialog(it)
        }
        /** 优惠券选中或非选中 */
        mViewModel.checkCouponResult.observe(viewLifecycleOwner) {
            onRefresh()
            couponListType = 1//取消或选中优惠券刷新接口
            showLoadingAntiShake()
            mViewModel.getCartCouponList(couponShopId)
        }
    }

    private fun initAdapter() {
        mDatabind.layoutList.swipeRecyclerView.init(LinearLayoutManager(context), mAdapter).addItemDecoration(
            SpaceItemDecoration(0, Util.dp2px(context, 10f))
        )

        mDatabind.layoutList.swipeRefreshLayout.init {
            onRefresh()
        }

        //状态页配置
        loadsir = loadServiceInit(mDatabind.layoutList.swipeRefreshLayout) {
            /** 点击重试时触发的操作 */
            onRefresh()
        }
    }

    private fun handleAdapter() {
        mAdapter.addChildClickViewIds(R.id.ivStoreSelected, R.id.tvItemShopName, R.id.ivItemShopName, R.id.llCoupon)
        mAdapter.setOnItemChildClickListener { _, view, position ->
            clickItemPosition = position
            when (view.id) {
                R.id.ivStoreSelected -> {
                    selectedGoods(mAdapter.data[position].shopId, position)
                }

                R.id.tvItemShopName, R.id.ivItemShopName -> {
                    nav().navigateAction(R.id.action_to_fragment_merchant_store, Bundle().apply {
                        putInt("shopId", mAdapter.data[position].shopId)
                    })
                }

                R.id.llCoupon -> {
                    couponListType = 2//获取优惠券列表
                    couponShopId = mAdapter.data[position].shopId
                    showLoadingAntiShake()
                    mViewModel.getCartCouponList(couponShopId)
                }
            }
        }

        mAdapter.setOnItemRemoveClickListener(object : ShopCarAdapter.OnItemRemoveClickListener {
            override fun onRemoveItemClick(id: Int) {
                //移除单件已失效的商品，待增加接口
            }
        })
        mAdapter.setOnItemDeleteClickListener(object : ShopCarAdapter.OnItemDeleteClickListener {
            override fun onDeleteItemClick(id: Int) {
                showDeleteCartOrderDialog(id)
            }
        })
        mAdapter.setOnItemAddClickListener(object : ShopCarAdapter.OnItemAddClickListener {
            override fun onAddItemClick(id: Int) {
                val body = AddOrReGoodsParam(id)
                mViewModel.addCount(body)
            }
        })
        mAdapter.setOnItemReClickListener(object : ShopCarAdapter.OnItemReClickListener {
            override fun onReItemClick(id: Int) {
                val body = AddOrReGoodsParam(id)
                mViewModel.reduceCount(body)
            }
        })
        mAdapter.setOnItemSpecClickListener(object : ShopCarAdapter.OnItemSpecClickListener {
            override fun onSpecItemClick(id: Int, position: Int, parentPosition: Int) {
                clickItemPosition = parentPosition
                goodsItemPosition = position
                showLoadingAntiShake(getString(R.string.loading))
                mViewModel.getGoodSkuList(id.toString())
            }
        })
        mAdapter.setOnItemIvCheckClickListener(object : ShopCarAdapter.OnItemIvCheckClickListener {
            override fun onIvCheckItemClick(position: Int, parentPosition: Int) {
                checkItem(position, parentPosition)
            }
        })
        mAdapter.setOnItemIvIconClickListener(object : ShopCarAdapter.OnItemIvIconClickListener {
            override fun onIvIconItemClick(goodId: Int) {
                nav().navigateAction(R.id.action_to_fragment_goods_detail, Bundle().apply {
                    putString("id", goodId.toString())
                })
            }
        })
    }

    private lateinit var dialogDeleteCartOrder: RxDialogDefault
    private fun showDeleteCartOrderDialog(id: Int) {
        dialogDeleteCartOrder = RxDialogDefault(context)
        dialogDeleteCartOrder.setTitle("确认删除此商品？")
        dialogDeleteCartOrder.setSureListener {
            showLoadingAntiShake(getString(R.string.loading))
            val body = AddOrReGoodsParam(id)
            mViewModel.deleteShopCart(body)
        }
        dialogDeleteCartOrder.setFullScreenWidth()
        dialogDeleteCartOrder.show()

    }

    private var mAdapterCoupon: CouponListAdapter? = null

    @SuppressLint("NotifyDataSetChanged", "MissingInflatedId")
    private fun showBottomCouponDialog(it: CartCouponListResponse) {
        if (mAdapterCoupon == null) {
            mAdapterCoupon = CouponListAdapter()
        }
        if (dialogBottom == null) {
            dialogBottom = context?.let { BottomSheetDialog(it, R.style.BottomSheetDialog) }!!
        }
        val dialogView: View = LayoutInflater.from(context).inflate(R.layout.bottom_coupon_list, null)
        val swipeRecyclerViewCoupon = dialogView.findViewById<SwipeRecyclerView>(R.id.swipeRecyclerViewCoupon)
        val ivCouponClose = dialogView.findViewById<AppCompatImageView>(R.id.ivCouponClose)
        val title = dialogView.findViewById<AppCompatTextView>(R.id.title)

        swipeRecyclerViewCoupon.init(LinearLayoutManager(context), mAdapterCoupon!!).addItemDecoration(
            SpaceItemDecoration(0, Util.dp2px(context, 10f))
        )
        ivCouponClose.setOnClickListener {
            dialogBottom!!.dismiss()
        }
        swipeRecyclerViewCoupon.adapter = mAdapterCoupon
        if (!it.isEmpty()) {
            mAdapterCoupon!!.setList(it.list)
            mAdapterCoupon!!.notifyDataSetChanged()
            title.text = "领取优惠券"
        } else {
            title.text = "暂无可用优惠券"
        }
        mAdapterCoupon!!.setOnBoxCheckedClickListener(object : CouponListAdapter.OnCheckedClickListener {
            override fun onBoxCheckedListener(isChecked: Boolean, position: Int) {
                val body = CheckCouponParam(
                    shopId = couponShopId,
                    couponId = mAdapterCoupon!!.data[position].id,
                    aboutId = mAdapterCoupon!!.data[position].aboutId,
                    useType = mAdapterCoupon!!.data[position].useType,
                    isCheck = isChecked,
                    selectId = mAdapterCoupon!!.data[position].selectId,
                )
                showLoadingAntiShake(getString(R.string.loading))
                mViewModel.checkCoupon(body)
            }
        })

        dialogBottom!!.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        dialogBottom!!.setContentView(dialogView)
        if (couponListType == 2) {
            dialogBottom!!.show()
        }
    }

    @SuppressLint("NotifyDataSetChanged", "SetTextI18n")
    private fun chooseAllItem() {
        /** 如果选中的条目数量和列表中的总数据相等 则取消全选 否则全部选中 */
        if (checkList.size == totalSize) {
            fullCheckOrCancelCheck(0)
        } else {
            fullCheckOrCancelCheck(1)
        }
    }

    private fun fullCheckOrCancelCheck(checkType: Int) {
        showLoadingAntiShake(getString(R.string.loading))
        val body = CarCheckedAllItemParam(checkType)//0 取消 1 勾选
        mViewModel.fullCheckOrCancelCheck(body)
    }

    private fun checkItem(position: Int, parentPosition: Int) {
        if (mAdapter.data[parentPosition].list[position].check == 1) {
            mAdapter.data[parentPosition].list[position].check = 0
            mAdapter.notifyItemChanged(position)
        } else {
            mAdapter.data[parentPosition].list[position].check = 1
            mAdapter.notifyItemChanged(position)
        }
        if (mAdapter.data[parentPosition].list[position].check == 1) {
            singleCheckOrUnChecked(mAdapter.data[parentPosition].list[position].id, 1)
        } else {
            singleCheckOrUnChecked(mAdapter.data[parentPosition].list[position].id, 0)
        }
    }

    private fun singleCheckOrUnChecked(id: Int, check: Int) {
        showLoadingAntiShake(getString(R.string.loading))
        val body = CarCheckedItemParam(id, check)//0 取消 1 勾选
        mViewModel.checkOrCancelCheck(body)
    }

    @SuppressLint("SetTextI18n")
    private fun showSKuListDialog(list: ArrayList<GoodsSkuResponse.ListBean>) {
        checkBean = null
        val rangeView = LayoutInflater.from(context).inflate(R.layout.single_select, null)
        val cancel = rangeView.findViewById<ImageView>(R.id.cancel)
        val sure = rangeView.findViewById<TextView>(R.id.sure)
        val choiceAreas = rangeView.findViewById<TextView>(R.id.choice_areas)
        val choiceInt = rangeView.findViewById<TextView>(R.id.choice_inventory)
        val choicePrice = rangeView.findViewById<TextView>(R.id.choice_price)
        val choicePic = rangeView.findViewById<ImageView>(R.id.choice_pic)
        val listView = rangeView.findViewById<View>(R.id.listView) as ListView
        val singleLevelAdapter = SingleLevelAdapter(context, list)
        listView.adapter = singleLevelAdapter

        listView.setOnItemClickListener { _, _, position, _ ->
            singleLevelAdapter.clear()
            SingleLevelAdapter.isSelected[position] = true
            checkBean = list[position]
            choiceAreas.text = list[position].specName
            choiceInt.text = "" + list[position].inventory
            choicePrice.text = "¥ " + list[position].salePrice
            ImageLoaderManager.loadRoundImageOrEmpty(context, list[position].specImgPath, choicePic, 5, R.mipmap.barrack_def_icon)
        }
        if (list.size != 0) {
            list.forEachIndexed { index, listBean ->
                if (listBean.id == goodsData[clickItemPosition].list[goodsItemPosition].specId) {
                    singleLevelAdapter.clear()
                    SingleLevelAdapter.isSelected[index] = true
                    checkBean = listBean
                    choiceAreas.text = listBean.specName
                    choiceInt.text = "" + listBean.inventory
                    choicePrice.text = "¥ " + listBean.salePrice
                    ImageLoaderManager.loadRoundImageOrEmpty(context, listBean.specImgPath, choicePic, 5, R.mipmap.barrack_def_icon)
                }
            }
        }
        val width = requireContext().screenWidth * 6 / 7
        val height = requireContext().screenHeight * 5 / 7
        singleRadioDialog = MyDialog(context, R.style.MySkuCarDialog, rangeView)

        singleRadioDialog!!.show()
        val lp = singleRadioDialog!!.window?.attributes
        if (lp != null) {
            lp.width = width
            lp.height = height
            lp.gravity = Gravity.CENTER
            singleRadioDialog!!.window!!.attributes = lp
        }
        cancel.setOnClickListener {
            singleRadioDialog!!.hide()
        }
        sure.setOnClickListener {
            singleRadioDialog!!.hide()
            if (checkBean == null) {
                RxToast.showToast(getString(R.string.market_shop_car_activity_please_select_sku))
                return@setOnClickListener
            }
            if (goodsData[clickItemPosition].list[goodsItemPosition].specId == checkBean!!.id) {
                singleRadioDialog!!.hide()
            } else {
                showLoadingAntiShake(getString(R.string.loading))
                val body = AddShoppingCarParam(
                    mAdapter.data[clickItemPosition].list[goodsItemPosition].id,
                    checkBean!!.id,
                    mAdapter.data[clickItemPosition].list[goodsItemPosition].buyCount
                )
                mViewModel.changeCartSpec(body)
            }
        }
    }

    private fun showRemoveInvalidDialog() {
        val dialog = RxDialogDefault(context)
        dialog.setTitle("确定移除全部失效商品？")
        dialog.setSureListener {
            dialog.dismiss()
            showLoadingAntiShake(getString(R.string.loading))
            mViewModel.removeInvalidGoods()
        }
        dialog.setFullScreenWidth()
        dialog.show()
    }

    private fun toOrderGoods() {
        if (checkList.size == 0) {
            RxToast.showToast(getString(R.string.market_shop_car_activity_please_select_product))
            return
        }
        if (totalPrice != null && totalPrice!!.toDouble() != 0.00) {
            showLoadingAntiShake(getString(R.string.loading))
            val body = GenerateShopOrderParam(totalPrice!!.toDouble(), addressId)
            mViewModel.generateShopOrder(body)
        } else {
            RxToast.showToast(getString(R.string.market_shop_car_activity_please_select_price))
        }
    }

    private fun selectedGoods(shopId: Int, position: Int) {
        val mCheck: Int
        if (mAdapter.data[position].check == 1) {
            mCheck = 0
            mAdapter.data[position].check = 0
            mAdapter.notifyItemChanged(position)
        } else {
            mCheck = 1
            mAdapter.data[position].check = 1
            mAdapter.notifyItemChanged(position)
        }
        showLoadingAntiShake(getString(R.string.loading))
        val param = CheckOrCancelShopParam(shopId = shopId, check = mCheck)
        mViewModel.checkOrCancelShop(param)
    }

    private fun setUIStatus(it: ListDataUiState<ShopCarListResponse.ListBean>) {
        totalSize = it.total
        /** 保存失效的商品 */
        val goodsList: ArrayList<Int> = arrayListOf()
        if (!it.isEmpty && it.listData!!.isNotEmpty()) {
            mDatabind.llBottom.visibility = View.VISIBLE
            mDatabind.llList.visibility = View.VISIBLE
            mDatabind.llToShopping.visibility = View.GONE
            goodsData = it.listData
            checkList.clear()
            it.listData.forEachIndexed { _, listBean ->
                if (!listBean.isEmpty()) {
                    listBean.list.forEachIndexed { _, listGoodsBean ->
                        if (listGoodsBean.isInvalid == 1) {
                            /** 若有已失效的商品 单独存进list */
                            goodsList.add(listGoodsBean.isInvalid)
                        }
                        if (listGoodsBean.check == 1) {
                            checkList.add(listGoodsBean.check)
                        }
                    }
                }
            }
            /** 保存已失效的商品list 若为空 代表没有 隐藏按钮 否则显示 */
            if (goodsList.size == 0) {
                mDatabind.includeWhiteBarMenu.tvRedBarRightMenu.visibility = View.GONE
            } else {
                mDatabind.includeWhiteBarMenu.tvRedBarRightMenu.visibility = View.VISIBLE
            }
            if (checkList.size == it.total) {
                mDatabind.ivShopCarGoodsChecked.setImageResource(R.mipmap.icon_good_check)
            } else {
                mDatabind.ivShopCarGoodsChecked.setImageResource(R.mipmap.icon_good_uncheck)
            }
            checkMoney(it.listData)
        } else {
            mDatabind.includeWhiteBarMenu.tvRedBarRightMenu.visibility = View.GONE
            eventViewModel.shopCarEmptyResult.value = true
            mDatabind.llToShopping.visibility = View.VISIBLE
            mDatabind.llBottom.visibility = View.GONE
            mDatabind.llList.visibility = View.GONE
        }
    }

    @SuppressLint("SetTextI18n")
    private fun checkMoney(it: ArrayList<ShopCarListResponse.ListBean>) {
        totalPrice = BigDecimal("0.00")
        it.forEachIndexed { _, listBean ->
            if (!listBean.isEmpty()) {
                listBean.list.forEachIndexed { _, listGoodsBean ->
                    if (listGoodsBean.check == 1) {
                        val price = BigDecimal(SettingUtil.div(listGoodsBean.finalPrice, 100.00, 2).toString())
                        totalPrice = totalPrice!!.add(price)
                    }
                }
            }
        }
        val totalPriceStr = totalPrice.toString()
        if (totalPriceStr.isNotEmpty() && totalPriceStr.contains(".")) {
            val integerY = totalPriceStr.split(".")
            if (integerY.isNotEmpty()) {
                RxTextTool.getBuilder("")
                    .append("总计:¥")
                    .append(integerY[0]).setBold().setAppearance(60).setTextColor(Color.BLACK)
                    .append(".")
                    .append(integerY[1])
                    .into(mDatabind.shopCarTotalPrice)
            }
        } else {
            mDatabind.shopCarTotalPrice.text = "总计:¥$totalPrice"
        }
    }
}